package com.zpark.service.impl;

import com.zpark.mapper.ISearchMapper;
import com.zpark.pojo.Search;
import com.zpark.service.ISearchService;
import com.zpark.service.ex.ZZSearchSearchTermsIsEmptyException;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xiaoyu
 * @version 1.0 2022/11/19
 */
@Service
public class SearchServiceImpl implements ISearchService {
    @Autowired
    private ISearchMapper iSearchMapper;

    @Override
    public List<Search> findBySearchTerms(String searchTerms) {
        if(StringUtils.isBlank(searchTerms)) {
            throw new ZZSearchSearchTermsIsEmptyException("搜索内容不能为空");
        }
        return iSearchMapper.selectBySearchTerms(searchTerms);
    }

    @Override
    public Integer getCount(String searchTerms) {

        return iSearchMapper.selectCount(searchTerms);
    }

    @Override
    public List<Search> findByBaidu(String hotword) {
        return iSearchMapper.selectByBaidu(hotword);
    }

    @Override
    public List<Search> findByReDian(String hotword) {
        return iSearchMapper.selectByReDian(hotword);
    }

    @Override
    public List<Search> findByDouYin(String hotword) {
        return iSearchMapper.selectByDouYin(hotword);
    }

    @Override
    public List<Search> findByJava(String hotword) {
        return iSearchMapper.selectByJava(hotword);
    }

    @Override
    public List<Search> findByXiaoHua(String hotword) {
        return iSearchMapper.selectByXiaoHua(hotword);
    }

    @Override
    public List<Search> findByEngineer(String hotword) {
        return iSearchMapper.selectByEngineer(hotword);
    }

    @Override
    public List<Search> findByFood(String hotword) {
        return iSearchMapper.selectByFood(hotword);
    }


}
